//新建投诉的 JS
$(function () {
    //点击事件<dialog open><dialog>遮盖方法
    $("#a_new").click(function () {
        $("#body").append("<dialog open  style='width: 804px;height: 625px;color: #FFFFFF'>" +
            "<div id='div1' style=\"background-color: #4e4f4a; border: 1px solid #4e4f4a; height: 100px;\n" +
            "top: -250px; left: 500px; width: 900px; position: absolute;\" onmousedown=\"mouseDown(this,event)\" onmousemove=\"mouseMove(event)\" onmouseup=\"mouseUp(event)\">\n" +
            "<span style='background-color: #6699CC;border: 1px solid #00B271; margin-left: 869px; padding: 10px 10px 10px 10px;color: #0a0a0a;' onclick='window.location.reload();'>X</span>" +
            "<iframe frameborder='1' style='margin-top: 10px'  id='div' scrolling='auto'  src='/j/complain/new' width='900px' height='608px'>" +
            "</iframe>" +
            "</div>" +
            "</dialog>");
    });




});

//下面是拖动框动作
var mouseX, mouseY;
var objX, objY;
var isDowm = false; //是否按下鼠标
var isUp = false;  //是否弹起鼠标
function mouseDown(obj, e) {
    obj.style.cursor = "move";
    objX = div1.style.left;
    objY = div1.style.top;
    mouseX = e.clientX;
    mouseY = e.clientY;
    isDowm = true;
}

function mouseMove(e) {
    var div = document.getElementById("div1");
    var x = e.clientX;
    var y = e.clientY;
    if (isDowm) {
        div.style.left = parseInt(objX) + parseInt(x) - parseInt(mouseX) + "px";
        div.style.top = parseInt(objY) + parseInt(y) - parseInt(mouseY) + "px";
        document.getElementById("span1").innerHTML = "x:" + div.style.top + " " + "y:" + div.style.left;
    }
}

function mouseUp(e) {
    if (isDowm) {
        var x = e.clientX;
        var y = e.clientY;
        var div = document.getElementById("div1");
        div.style.left = (parseInt(x) - parseInt(mouseX) + parseInt(objX)) + "px";
        div.style.top = (parseInt(y) - parseInt(mouseY) + parseInt(objY)) + "px";
        document.getElementById("span2").innerHTML = "x:" + div.style.top + " " + "y:" + div.style.left;
        mouseX = x;
        rewmouseY = y;
        div1.style.cursor = "default";
        isDowm = false;
    }
}